﻿using System.Collections.Generic;
using Models;
using System;

namespace Views
{
    /// <summary>
    /// Interface that contains details about a query view
    /// </summary>
    public interface IQueryView : IView
    {
        /// <summary>
        /// The query that is currently loaded into the view
        /// </summary>
        Query LoadedQuery
        {
            get;
            set;
        }

        /// <summary>
        /// Whether of not the query has been modified since it was loaded or saved into the view
        /// </summary>
        bool IsDirty
        {
            get;
            set;
        }

        /// <summary>
        /// Whether this query view has been selected to have its contents saved, used by the ISaveItem view that is displayed
        /// when the application is shut down
        /// </summary>
        bool SelectedForSaving
        {
            get;
            set;
        }

        /// <summary>
        /// The name that the query is saved under
        /// </summary>
        string QueryName
        {
            get;
            set;
        }

        /// <summary>
        /// The currently selected and displayed result set
        /// </summary>
        QueryResult SelectedResult
        {
            get;
            set;
        }

        /// <summary>
        /// The currently selected database
        /// </summary>
        Database SelectedDatabase
        {
            get;
            set;
        }

        /// <summary>
        /// List of databases currently displayed in the Query Tab
        /// </summary>
        List<Database> DisplayedDatabases
        {
            get;
            set;
        }

        /// <summary>
        /// List of all databases currently loaded into the Query Tab
        /// </summary>
        List<Database> DatabaseList
        {
            get;
            set;
        }

        /// <summary>
        /// The name of the currently loaded database list
        /// </summary>
        string DatabaseListName
        {
            get;
            set;
        }

        /// <summary>
        /// If this is true then the database list has been updated and not saved
        /// </summary>
        bool IsListDirty
        {
            get;
            set;
        }

        /// <summary>
        /// When this is true the user can edit the database list and the query itself
        /// </summary>
        /// <remarks>This is used to lock certain parts of the interface when the user is running a query</remarks>
        bool EditorEnabled
        {
            get;
            set;
        }

        /// <summary>
        /// Text to display in the status area
        /// </summary>
        string Status
        {
            get;
            set;
        }

        /// <summary>
        /// When a query batch is running, how far through the process we have got
        /// </summary>
        int Progress
        {
            get;
            set;
        }

        /// <summary>
        /// A dictionary of server plugins to use in the filter options
        /// </summary>
        Dictionary<Guid, string> AvailablePlugins
        {
            get;
            set;
        }

        /// <summary>
        /// The currently selected plug in ID
        /// </summary>
        Guid SelectedPluginID
        {
            get;
            set;
        }

        /// <summary>
        /// Contains the text filter to apply to the database/server name
        /// </summary>
        string DatabaseNameFilter
        {
            get;
            set;
        }

        /// <summary>
        /// Whether or not to filter for databases that have successfull queries against them
        /// </summary>
        bool SuccessfullQueryFilter
        {
            get;
            set;
        }

        /// <summary>
        /// Whether or not the filter is currently applied to the database list
        /// </summary>
        bool FilterApplied
        {
            get;
            set;
        }

        /// <summary>
        /// Refrsh the items in the database grid
        /// </summary>
        void RefreshDataGrid();
    }
}
